/*
package com.demo.config;

import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;

import javax.sql.DataSource;

@Slf4j
@Configuration
@MapperScan(basePackages = "com.demo.mapper.demo.**", sqlSessionFactoryRef = "sqlSessionFactoryDemo")
public class DataSourceConfigDemo {

    @Primary
    @Bean(name = "dataSourceDemo")
    @ConfigurationProperties(prefix = "spring.datasource.demo")
    public DataSource dataSource() {
        return DataSourceBuilder.create().type(HikariDataSource.class)
                .build();
    }

    @Bean(name = "sqlSessionFactoryDemo")
    public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSourceDemo") DataSource dataSource) throws Exception {
        MybatisSqlSessionFactoryBean sessionFactoryBean = new MybatisSqlSessionFactoryBean();
        sessionFactoryBean.setDataSource(dataSource);
        sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver()
                .getResources("classpath*:mapper/demo/*.xml"));
        log.info("------dataSource demo 配置成功");
        return sessionFactoryBean.getObject();
    }

    @Bean(name = "sqlSessionTemplateDemo")
    public SqlSessionTemplate sqlSessionFactoryTemplate(@Qualifier("sqlSessionFactoryDemo") SqlSessionFactory sqlSessionFactory) {
        return new SqlSessionTemplate(sqlSessionFactory);
    }

    @Bean(name = "txManagerDemo")
    public PlatformTransactionManager txManager(@Qualifier("dataSourceDemo") DataSource dataSource) {
        return new DataSourceTransactionManager(dataSource);
    }
}
*/
